﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls.Adapters;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FaithCMS
{
    public class ListAdapter : WebControlAdapter
    {
        protected override void RenderBeginTag(HtmlTextWriter writer)
        {
            writer.Indent++;
            writer.Indent++;
            writer.WriteBeginTag("div");
            writer.Write(HtmlTextWriter.TagRightChar);
            writer.WriteLine();
        }

        protected override void RenderEndTag(HtmlTextWriter writer)
        {
            writer.Indent--;
            writer.WriteEndTag("div");
            writer.WriteLine();
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            writer.Indent++;

            BulletedList bl = Control as BulletedList;

            if (bl != null)
            {
                foreach (ListItem i in bl.Items)
                {
                    writer.WriteBeginTag("span");
                    writer.WriteAttribute("id", "listItem");
                    writer.Write(HtmlTextWriter.TagRightChar);
                    writer.Write("@");
                    writer.Write(HtmlTextWriter.SpaceChar);
                    writer.Write(i.Text);
                    writer.WriteEndTag("span");
                    writer.WriteBreak();
                    writer.WriteLine();
                }
            }

            writer.Indent--;
        }
    }
}